<?php include_once(TEMPLATE_PATH.'includes/ads_slideshow.php'); ?>
<!-- main row -->
<div class="row bg-white b-t ">
  <?php include_once(TEMPLATE_PATH.'includes/ads_top_left.php'); ?>
  <?php include_once(TEMPLATE_PATH.'includes/category.php'); ?>
  <?php include_once(TEMPLATE_PATH.'includes/ads_top_right.php'); ?>
</div><!-- main row -->

<?php include_once(TEMPLATE_PATH.'includes/ads_middle.php'); ?>

<!-- main row product -->
<div class="row bg-white">
  <?php include_once(TEMPLATE_PATH.'includes/ads_left.php'); ?>
  <!-- Content -->
  <div class="col-sm-6 ">
      
    <div class="row">
      <div class="col-md-4"><h4>Latest advertisement:</h4></div>
      <div class="col-md-6 text-left">
        <form role="search" action="<?php echo site_url('home'); ?>">
          <div class="form-group m-b">
            <div class="input-group">
            <input type="text" name="q" value="<?php echo $q; ?>" class="form-control" placeholder="Search">
            <span class="input-group-btn">
              <button type="submit" class="btn btn-info btn-icon"><i class="fa fa-search"></i></button>
            </span>
            </div>
          </div>
        </form>
      </div>
    </div>

<?php if(isset($data) && $data->num_rows() > 0): ?>
  <?php 
    $i = 1;
    $num_rows = $data->num_rows();
  ?>
  <?php foreach($data->result_array() as $row): ?>

  <?php if(($i % 4) === 1): ?>
    <div class="row text-center">
  <?php endif; ?>
      <div class="col-xs-6 col-md-3">
          <a href="<?php echo site_url('detail/'.$row[field('id')]); ?>" class="thumbnail text-center ">
            <img src="<?php echo base_url(UPLOAD_PATH . ($row[field('image')] ? 'ads/250x250/' . $row[field('image')] : IMAGE_DEFAULT)); ?>" alt="" title="<?php echo $row[field('title')]; ?>" class="thumb">
          <div class="bran_title"><?php echo $row[field('title')]; ?></div>
            <span class="text-danger">Price: <?php echo $row[field('price')]; ?> $</span>
          </a>
      </div>
  <?php if(($i % 4) === 0 || $num_rows == $i): ?>
    </div>
  <?php endif; ?>
  <?php $i++; ?>

  <?php endforeach; ?>
<?php else: ?>
  <p><?php echo SEACH_NOT_FOUND; ?></p>
<?php endif; ?>

    <div class="text-center col-xs-12 col-md-12 m-b">
      <?php echo $this->pagination->create_links(); ?>
    </div>
  </div>

  <!-- End Content -->
  <?php include_once(TEMPLATE_PATH.'includes/ads_right.php'); ?>
</div><!-- main row product -->

<?php include_once(TEMPLATE_PATH.'includes/ads_bottom.php'); ?>
<!-- 
<div class="text-center m-b">
  <ul class="pagination pagination-md">
    <li><a href="#"><i class="fa fa-chevron-left"></i></a></li>
    <li class="active"><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">5</a></li>
    <li><a href="#"><i class="fa fa-chevron-right"></i></a></li>
  </ul>
</div> --> <!-- END pagination -->
